package com.lanxin.config;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * swagger配置类
 * @author cyh
 * @create 2025-09-03 10:02
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket testApis() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apidoc())
                .select()
                 //指定扫描的controller接口包
                //.apis(RequestHandlerSelectors.basePackage("com.lanxin.*.controller"))
                .apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
                .paths(PathSelectors.any())
                .build()
                .groupName("测试服务")
                .enable(true);
    }
    private ApiInfo apidoc() {
        return new ApiInfoBuilder()
                .title("测试接口")
                .description("接口文档")
                .contact(new Contact("demo", "#", "cyh_it@163.com"))
                .version("1.0")
                .build();
    }
}